Backport gh-226 to maintenance/0.4.x: add getter for NumPy ufunc types#233
Merged
Conversation
NumPy 2.5+ changed how the types property is exposed in NumPy, causing indexing on the types to break. Adds a _get_ufunc_types getter defined as cdef extern that accesses the ufunc struct directly, working with NumPy 2.5 and previous versions. Also fixes a bug where patching would attempt to free null pointers when the patching process fails midway. Backport of gh-226 to maintenance/0.4.x. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jharlow-intel
approved these changes
Jun 30, 2026
jharlow-intel
left a comment
Collaborator
There was a problem hiding this comment.
Looks good! Build failures are machine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backports #226 to the
maintenance/0.4.xbranch.NumPy 2.5 changed how the
typesproperty is exposed withufunc.types, which causedmkl_umathto crash during patching on pre-release NumPy. This adds a_get_ufunc_typesgetter (defined in_patch_numpy.pyxascdef extern) that works with NumPy 2.5 and previous versions by accessing the ufunc struct directly.Additionally slips in changes which prevent attempting to free a nullptr when the patch fails (i.e., due to
RuntimeError).The
_patch_numpy.pyxchange applies identically to the original PR (the file matched the PR base on this branch). The CHANGELOG entry is placed under a new[dev]section since this branch had no unreleased section.🤖 Generated with Claude Code